<%--
  Created by IntelliJ IDEA.
  User: taohj
  Date: 2014/6/29
  Time: 18:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<c:set var="dashboardMenuTag" value="myorg" scope="request"></c:set>
<c:set var="menu" value="none" scope="request"></c:set>

<!Doctype html>
<html>
<head>
    <base href="<%=basePath%>">
    <title>政府数据开放平台</title>
    <jsp:include page="../../../commons/include.jsp"/>

    <link href="/resources/css/lib.css" rel="stylesheet">


    <script>
        $(function () {
            $(".pagination li").on('click', function () {
                $('form input[name="page"]').val($(this).attr("page"));
                $("form").submit();
            });
            var org = $(".table").attr("org");

            $(".table tbody tr").each(function () {

                var role = $(this).attr("role");

                $(this).find(":last-child>ul>li:first").on('click', function () {
                    location.href = '/front/my/org/role/modifyV?id=' + role;
                });

                $(this).find(":last-child>ul>li:last").on('click', function () {

                    var n = noty({
                        text: '<span style="font-size: 14px;">确定要删除吗?</span>', layout: 'topCenter',
                        buttons: [
                            {addClass: 'btn btn-primary', text: '确定', onClick: function ($noty) {
                                $noty.close();

                                $.post('/front/my/org/role/remove', {id:role}, function (result) {

                                    if (result.success) {
                                        var n = noty({text: result.message, type: 'success',
                                            timeout:800,
                                            type:'success',
                                            layout:'topCenter',
                                            callback: {
                                                onClose: function () {
                                                    location.href =location.href;
                                                }
                                            }});
                                    }else{
                                        var n = noty({
                                            text: result.message,
                                            type: 'error',
                                            type:'success',
                                            layout:'topCenter'
                                        });
                                    }
                                }, 'json');




                            }
                            },
                            {addClass: 'btn btn-danger', text: '取消', onClick: function ($noty) {
                                $noty.close();

                            }
                            }
                        ]
                    });


                });
            });
        });
    </script>


</head>
<body>


<jsp:include page="../../../commons/top.jsp"/>

<div class="main" style="min-height: 600px">
    <jsp:include page="../../../commons/dashboardMenu.jsp"/>


    <div>
        <div class="left">
            <c:set var="leftMenu" value="role" scope="request"></c:set>
            <jsp:include page="../commons/leftMenu.jsp"/>
        </div>
        <div class="right">
            <div style="width: 100%;padding: 20px 0px 20px 20px; float: left;">

                <div style="height: 40px; ">
                    <input type="button" class="btn btn-primary"
                           onclick="location.href='/front/my/org/role/createV?org=${requestScope.org}'"
                           value="新&nbsp;&nbsp;&nbsp;增">
                </div>

                <div>
                    <form action="/front/my/org/role/list">
                        <input type="hidden" name="page">
                        <input type="hidden" name="org" value="${requestScope.org}">

                        <div>
                            <input type="text" name="name" value="${requestScope.result.pageResult.t.name}"
                                   style="height: 30px;width: 300px"><input type="submit" value="搜索"
                                                                            style="height: 34px">
                        </div>
                        <div style="height: 50px;line-height: 30px;font-size: 14px;font-weight: bold;padding: 10px">
                            排序：<select name="order" style="width: 100px;font-size: 14px;">
                            <option value="asc">名称升序</option>
                            <option value="desc"
                                    <c:if test="${requestScope.result.pageResult.sortBy=='desc'}">selected="selected" </c:if> >
                                名称降序
                            </option>
                        </select>
                        </div>
                    </form>
                </div>
            </div>


            <div style="padding: 20px 20px">
                <span style="font-size: 16px;font-weight: bold;">共找到条${requestScope.result.pageResult.total}记录</span>
            </div>

            <div style="padding: 10px;">
                <div style="min-height: 460px">
                    <table class="table" width="100%" org="${requestScope.org}">
                        <thead>
                        <tr>
                            <td width="50">序号</td>
                            <td>名称</td>
                            <td>机构</td>
                            <td>简介</td>
                            <td>操作</td>
                        </tr>
                        </thead>

                        <tbody>
                        <c:forEach items="${requestScope.result.pageResult.rows}" var="role" varStatus="status">
                            <tr role="${role.id}">
                                <td>${(requestScope.result.pageResult.page-1)*requestScope.result.pageResult.size+status.count}</td>
                                <td>${role.name}</td>
                                <td>${role.org.name}</td>
                                <td>${role.description}</td>
                                <td style="text-align: left">

                                    <ul id="icons" class="ui-widget ui-helper-clearfix">
                                        <li class="ui-state-default ui-corner-all" title="更新"><span class="ui-icon ui-icon-pencil"></span></li>
                                        <li class="ui-state-default ui-corner-all" title="授权"><span class="ui-icon ui-icon-check"></span></li>
                                        <li class="ui-state-default ui-corner-all" title="删除"><span class="ui-icon ui-icon-trash"></span></li>
                                    </ul>
                                </td>
                            </tr>

                        </c:forEach>
                        </tbody>
                    </table>

                </div>


            </div>


            <div>
                <ul class="pagination" style="margin: 20px 30px;">
                    <li page="${requestScope.result.pageResult.startPage-1}">
                        &laquo;
                    </li>

                    <c:forEach begin="${requestScope.result.pageResult.startPage}"
                               end="${requestScope.result.pageResult.endPage}" var="index">
                        <li page="${index}" <c:if
                                test="${index==requestScope.result.pageResult.page}"> class="active" </c:if>>${index}
                        </li>
                    </c:forEach>

                    <li page="${requestScope.result.pageResult.endPage+1}">
                        &raquo;
                    </li>
                </ul>
            </div>

        </div>

    </div>

</div>


<jsp:include page="../../../commons/buttom.jsp"/>
</body>
</html>
